﻿@{
    if(IsPost)
    {
        Response.Cookies["cart"]["user"] = WebSecurity.CurrentUserName;
        // if cookies is not null and length is more than 0, append item id, else we have first one
        var items = (Request.Cookies["cart"]["items"] != null && Request.Cookies["cart"]["items"].Length > 0) 
            ? Request.Cookies["cart"]["items"] + "," + Request["itemId"] 
            : Request["itemId"];
        Response.Cookies["cart"]["items"] = items;
        Response.Cookies["cart"].Expires = DateTime.Now.AddDays(5);
    }
}